package roborally.Pieces;
import be.kuleuven.cs.som.annotate.*;

/**
 * This is a class of Carriable Pieces that have a weight and possibly a Position on a Board.
 * @invar getWeight() >= 0
 * @invar The position is valid 
 * 		| Position.isValidPosition(getPosition().getX(), getPosition().getY(), getPosition().getBoard() )
 * @version 2.0
 * @author Bart Opsomer 2de Bachelor Ingenieurswetenschappen Electrotechniek-Computerwetenschappen 
 * 		   Peter Opsomer 1ste Master Wiskundige IngenieursTechnieken
 */
public abstract class CarriablePiece extends GamePieceWithoutOrientation {
	private int weight;
	/**
	 * Create a new CarriablePiece with a given weight Since weight is implemented totally and weights are positive, we 
	 * use the absolute value. It is assumed that the weight cannot change, so no method to set the weight is given.
	 * 
	 * @param weight the modulus of the weight of the new CarriablePiece
	 * @effect| super()
	 * @post  | this.getWeight() == Math.abs(weight)
	 */
	@Raw @Model
	protected CarriablePiece(int weight) {
		this.weight = Math.abs(weight);
	}
	/**
	 * @return weight of the CarriablePiece in grams
	 */
	@Basic
	public int getWeight() {
		return weight;
	}
	/**
	 * Return a String to be added to the toString()-methods of subclasses. This method is not abstract, but subclasses should overwrite this
	 * method to get a representative name for them in the GUI. This method gives information about the weight and then the position of the CarriablePiece.
	 * 
	 * @return | result.endsWith(" and weight " + getWeight() + super.toString() )
	 */
	@Override
	public String toString(){
		return " and weight " + weight + super.toString();
	}
	/**
	 * 
	 * Use the carriable item
	 * @param robot the robot which uses this item
	 */
	public abstract void use(Robot robot) ;

}
